/*
 *
 * Copyright (C) 2012 Walter Lütgenau
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */
package offset.nodes.client.dialog.io.view;

import javax.jcr.ImportUUIDBehavior;

/**
 *
 * @author  Walter Lütgenau
 */
public class ImportPanel extends javax.swing.JPanel {
    
    /** Creates new form ExportPanel */
    public ImportPanel() {
        initComponents();
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jPanel1 = new javax.swing.JPanel();
        createNewRadio = new javax.swing.JRadioButton();
        removeExistingRadio = new javax.swing.JRadioButton();
        replaceExistingRadio = new javax.swing.JRadioButton();
        denyRadio = new javax.swing.JRadioButton();

        java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("offset/nodes/client/dialog/view/DialogBundle"); // NOI18N
        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("import.importOptions"))); // NOI18N

        buttonGroup1.add(createNewRadio);
        createNewRadio.setSelected(true);
        createNewRadio.setText(bundle.getString("import.createNew")); // NOI18N

        buttonGroup1.add(removeExistingRadio);
        removeExistingRadio.setText(bundle.getString("import.removeExisting")); // NOI18N

        buttonGroup1.add(replaceExistingRadio);
        replaceExistingRadio.setText(bundle.getString("import.replaceExisting")); // NOI18N

        buttonGroup1.add(denyRadio);
        denyRadio.setText(bundle.getString("import.deny")); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(createNewRadio)
                    .addComponent(removeExistingRadio)
                    .addComponent(replaceExistingRadio)
                    .addComponent(denyRadio))
                .addContainerGap(110, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(createNewRadio)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(removeExistingRadio)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(replaceExistingRadio)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(denyRadio)
                .addContainerGap(26, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(72, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents
    
    public int getUuidBehaviour() {
        if (createNewRadio.isSelected())
            return ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW;
        else if (removeExistingRadio.isSelected())
            return ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING;
        else if (replaceExistingRadio.isSelected())
            return ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING;
        
        return ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW;
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JRadioButton createNewRadio;
    private javax.swing.JRadioButton denyRadio;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JRadioButton removeExistingRadio;
    private javax.swing.JRadioButton replaceExistingRadio;
    // End of variables declaration//GEN-END:variables
    
}
